/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qjs.smterp.jpa;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.qjs.smterp.model.Stock;
@Repository("stockDao")
public class StockDaoImpl extends AbstractHibernateDAOImpl<Stock, Long> implements StockDao , Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected Class<Stock> getDomainClass() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Stock findByCode(String code) {
		// TODO Auto-generated method stub
		Query query = getSession().getNamedQuery("Stock.findByStockCode");
		query.setParameter("stockCode", code);		
		return (Stock) query.uniqueResult();
	}

	@Override
	public Stock findById(int Id) {
		// TODO Auto-generated method stub
		return (Stock)getSession().getNamedQuery("Stock.findByStockId").setParameter("stockId", Id).uniqueResult();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Stock> findByAll() {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("Stock.findAll").list();
	}
   
    
}
